package gxb.test04;

import java.util.Scanner;

public class StringManips {
    public static void main(String[] args) {
        String phrase = new String("This is a String test");
        int phraseLength;
        int middleIndex;
        String firstHalf;
        String secondHalf;
        String swithchedPhrase;
        phraseLength=phrase.length();
        middleIndex=phraseLength;
        String middle3;
        String city,state;

        firstHalf = phrase.substring(0,middleIndex);
        secondHalf= phrase.substring(middleIndex,phraseLength);
        swithchedPhrase= secondHalf.concat(firstHalf);
        middle3= phrase.substring(9,12);
        String switchPhrase= swithchedPhrase.replace(" ","*");

        System.out.println();
        System.out.println("Original pharse:"+phrase);
        System.out.println("Length of the phrase:"+phraseLength+"characters");
        System.out.println("Index of the middle:"+middleIndex);
        System.out.println("Character at the middle index:"+phrase.charAt(middleIndex-1));
        System.out.println("Switched phrase:"+swithchedPhrase);
        System.out.println(middle3);
        System.out.println(switchPhrase);

        Scanner sc = new Scanner(System.in);
        System.out.println("请输入籍贯所在的city:");
        city= sc.nextLine();
        System.out.println("请输入籍贯所在的state:");
        state=sc.nextLine();
        String newStr = state.toUpperCase()+city.toLowerCase()+state.toUpperCase();
        System.out.println(newStr);

        System.out.println();
    }
}
